/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package xcore.model.util;

import java.util.List;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;

import xcore.model.*;

/**
 * <!-- begin-user-doc -->
 * The <b>Switch</b> for the model's inheritance hierarchy.
 * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
 * to invoke the <code>caseXXX</code> method for each class of the model,
 * starting with the actual class of the object
 * and proceeding up the inheritance hierarchy
 * until a non-null result is returned,
 * which is the result of the switch.
 * <!-- end-user-doc -->
 * @see xcore.model.ModelPackage
 * @generated
 */
public class ModelSwitch<T> {
	/**
	 * The cached model package
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected static ModelPackage modelPackage;

	/**
	 * Creates an instance of the switch.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ModelSwitch() {
		if (modelPackage == null) {
			modelPackage = ModelPackage.eINSTANCE;
		}
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	public T doSwitch(EObject theEObject) {
		return doSwitch(theEObject.eClass(), theEObject);
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	protected T doSwitch(EClass theEClass, EObject theEObject) {
		if (theEClass.eContainer() == modelPackage) {
			return doSwitch(theEClass.getClassifierID(), theEObject);
		}
		else {
			List<EClass> eSuperTypes = theEClass.getESuperTypes();
			return
				eSuperTypes.isEmpty() ?
					defaultCase(theEObject) :
					doSwitch(eSuperTypes.get(0), theEObject);
		}
	}

	/**
	 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
	 * @generated
	 */
	protected T doSwitch(int classifierID, EObject theEObject) {
		switch (classifierID) {
			case ModelPackage.XCLASS: {
				XClass xClass = (XClass)theEObject;
				T result = caseXClass(xClass);
				if (result == null) result = caseXElement(xClass);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XREFERENCE: {
				XReference xReference = (XReference)theEObject;
				T result = caseXReference(xReference);
				if (result == null) result = caseXFeature(xReference);
				if (result == null) result = caseXElement(xReference);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XELEMENT: {
				XElement xElement = (XElement)theEObject;
				T result = caseXElement(xElement);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XATTRIBUTE: {
				XAttribute xAttribute = (XAttribute)theEObject;
				T result = caseXAttribute(xAttribute);
				if (result == null) result = caseXFeature(xAttribute);
				if (result == null) result = caseXElement(xAttribute);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XFEATURE: {
				XFeature xFeature = (XFeature)theEObject;
				T result = caseXFeature(xFeature);
				if (result == null) result = caseXElement(xFeature);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.MODEL: {
				Model model = (Model)theEObject;
				T result = caseModel(model);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XOBJECT: {
				XObject xObject = (XObject)theEObject;
				T result = caseXObject(xObject);
				if (result == null) result = caseXElement(xObject);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XRELATION: {
				XRelation xRelation = (XRelation)theEObject;
				T result = caseXRelation(xRelation);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.INSTANCE: {
				Instance instance = (Instance)theEObject;
				T result = caseInstance(instance);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XREF_FEATURE: {
				XRefFeature xRefFeature = (XRefFeature)theEObject;
				T result = caseXRefFeature(xRefFeature);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XATT_FEATURE: {
				XAttFeature xAttFeature = (XAttFeature)theEObject;
				T result = caseXAttFeature(xAttFeature);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XVAR_VALUES: {
				XVarValues xVarValues = (XVarValues)theEObject;
				T result = caseXVarValues(xVarValues);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XVAR_ATTRIBUTE: {
				XVarAttribute xVarAttribute = (XVarAttribute)theEObject;
				T result = caseXVarAttribute(xVarAttribute);
				if (result == null) result = caseXAttribute(xVarAttribute);
				if (result == null) result = caseXFeature(xVarAttribute);
				if (result == null) result = caseXElement(xVarAttribute);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XCST_ATTRIBUTE: {
				XCstAttribute xCstAttribute = (XCstAttribute)theEObject;
				T result = caseXCstAttribute(xCstAttribute);
				if (result == null) result = caseXAttribute(xCstAttribute);
				if (result == null) result = caseXFeature(xCstAttribute);
				if (result == null) result = caseXElement(xCstAttribute);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			case ModelPackage.XCST_VALUES: {
				XCstValues xCstValues = (XCstValues)theEObject;
				T result = caseXCstValues(xCstValues);
				if (result == null) result = defaultCase(theEObject);
				return result;
			}
			default: return defaultCase(theEObject);
		}
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XClass</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XClass</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXClass(XClass object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XReference</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XReference</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXReference(XReference object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XElement</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XElement</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXElement(XElement object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XAttribute</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XAttribute</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXAttribute(XAttribute object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XFeature</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XFeature</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXFeature(XFeature object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Model</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Model</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseModel(Model object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XObject</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XObject</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXObject(XObject object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XRelation</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XRelation</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXRelation(XRelation object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>Instance</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>Instance</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseInstance(Instance object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XRef Feature</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XRef Feature</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXRefFeature(XRefFeature object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XAtt Feature</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XAtt Feature</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXAttFeature(XAttFeature object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XVar Values</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XVar Values</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXVarValues(XVarValues object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XVar Attribute</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XVar Attribute</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXVarAttribute(XVarAttribute object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XCst Attribute</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XCst Attribute</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXCstAttribute(XCstAttribute object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>XCst Values</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>XCst Values</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
	 * @generated
	 */
	public T caseXCstValues(XCstValues object) {
		return null;
	}

	/**
	 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
	 * <!-- begin-user-doc -->
	 * This implementation returns null;
	 * returning a non-null result will terminate the switch, but this is the last case anyway.
	 * <!-- end-user-doc -->
	 * @param object the target of the switch.
	 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
	 * @generated
	 */
	public T defaultCase(EObject object) {
		return null;
	}

} //ModelSwitch
